//
//  NavigationViewDemo.swift
//  SwiftUIDemo
//
//  Created by Tilt Wang on 2025/6/29.
//

import SwiftUI

struct NavigationViewDemo: View {
    var body: some View {
        
        NavigationView {
            ScrollView {
                NavigationLink("hello world !") {
                    MyOtherScreen()
                }
                Text("1111")
                Text("1111")
                Text("1111")
                Text("1111")
            }
            .navigationTitle("3334444444444444444444444444444444444")
//            .navigationBarTitleDisplayMode(.automatic)
//            .navigationBarHidden(true)
            .navigationBarItems(
                leading:
                    HStack {
                        Image(systemName: "person.fill")
                        Image(systemName: "flame.fill")
                    },
                trailing: NavigationLink(
                    destination: MyOtherScreen(),
                    label: {
                    Image(systemName: "gear")
                })
                .accentColor(.red)
            )
        }
    }
}

struct MyOtherScreen: View {
    
    @Environment(\.presentationMode) var presentationMode
    
    var body: some View {
        ZStack {
            Color.green.edgesIgnoringSafeArea(.all)
                .navigationTitle("Green Screen")
                .navigationBarHidden(true)
            VStack {
                Button {
                    presentationMode.wrappedValue.dismiss()
                } label: {
                    Image(systemName: "xmark")
                        .foregroundColor(.white)
                        .font(.largeTitle)
                        .padding(20)
                }

                NavigationLink("jump to next") {
                    Text("Three Screen")
                }
            }
        }
    }
}


#Preview {
    NavigationViewDemo()
}
